#include <iostream>
#include <string>
#include <map>

std::string str;

namespace force {
const int N = 25;
const int M = 1 << 18 | 5;
int ans = 0;

bool vis[N][M];

inline void dfs(int str, int len) {
	if(vis[len][str]) return;
	for(int i = 0; i < len; ++i) std::cerr << char('A' + (str >> i & 1)); std::cerr << "\n";
	vis[len][str] = 1;
	++ans;
	for(int i = 0; i + 1 < len; ++i) {
		int x = str >> i & 1;
		int y = str >> (i + 1) & 1;
		if(x >= y) {
			int s0 = str & ((1 << i) - 1) | (str >> (i + 2) << i);
			dfs(s0, len - 2);
		}
	}
}

void solve() {
	int b = 0;
	for(int i = 0; i < str.size(); ++i) b |= (str[i] == 'B') << i;
	dfs(b, str.size());
	std::cout << ans << "\n";
}

}

int main() {
	std::freopen("song.in", "r", stdin);
	std::freopen("song.out", "w", stdout);

	std::cin >> str;
	if(str.size() <= 20) {
		force::solve();
	} else {
		int len = str.size();
		if(str[0] == 'A') --len;
		std::cout << len / 2 + 1 << "\n";
	}

	return 0;
}
